<template>
    <div>
        <!-- seach区域 -->
        <div class="seach">
            <span class="SUP">
                <span class="seachCSC">
                    {{$t('logtyp')}}
                    <el-select v-model="logMgeForm.logType" :placeholder="$t('plsset')" size="mini">
                        <el-option :label="'-' + $t('plsset') + '-'" :value="null"></el-option>
                    </el-select>
                </span>
                <span class="seachCSC">
                    {{$t('opr')}}
                    <el-select v-model="logMgeForm.operator" :placeholder="$t('plsset')" size="mini">
                        <el-option :label="'-' + $t('plsset') + '-'" :value="null"></el-option>
                    </el-select>
                </span>
                <span class="seachStatus">
                    {{$t('opratntim')}}
                    <el-date-picker :placeholder="$t('plsset')" v-model="logMgeForm.operationTime " width="20%" type="date" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" size="mini"></el-date-picker>
                </span>
            </span>
            <div class="NOUS">
                <el-button type="primary" @click="seach" size="mini" v-preventReClick>{{$t('qury')}}</el-button>
                <el-button type="success" @click="exportExcel" size="mini" v-preventReClick>{{$t('expot')}}</el-button>
            </div>
        </div>
        <!-- 内容区域 -->
        <el-card class="cardBox">
            <el-table border style="width: 100%" :data="logMgeTab" id="out-table">
                <el-table-column type="index" :label="$t('sernum')">
                </el-table-column>
                <el-table-column prop="merId" :label="$t('opratntim')">
                </el-table-column>
                <el-table-column prop="merName" :label="$t('logtyp')">
                </el-table-column>
                <el-table-column prop="sendChannelOrderNo" :label="$t('operationfunction')">
                </el-table-column>
                <el-table-column prop="channelCode" :label="$t('opr')">
                </el-table-column>
                <el-table-column prop="payStatus" :label="$t('operationtimes')">
                </el-table-column>
                <el-table-column prop="amt" :label="$t('operationresult')">
                </el-table-column>
                <el-table-column prop="address" :label="$t('opratn')" width="100" fixed="right">
                    <template slot-scope="scope">
                        <el-link type="primary" @click="detaillogMgr(scope.row)">{{$t('detls')}}</el-link>
                        <el-link type="primary" @click="removelogMgr(scope.row)">{{$t('dlte')}}</el-link>
                    </template>
                </el-table-column>
            </el-table>
            <!-- 分页 -->
            <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="logMgeForm.pageNum"
                :page-sizes="[10, 15, 20, 30]"
                :page-size="logMgeForm.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
            </el-pagination>
        </el-card>
    </div>
</template>

<script>
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
export default {
    data () {
        return {
            total: 0,
            logMgeForm: {
                logType: null,
                operator: null,
                operationTime: null,
                pageNum: 1,
                pageSize: 10
            },
            logMgeTab: []
        }
    },
    methods: {
        seach () {},
        detaillogMgr () {},
        removelogMgr () {},
        handleSizeChange (newSize) {
            this.selMrec.pageSize = newSize
            this.seachMonRec()
        },
        // 监听总页数变化
        handleCurrentChange (newNum) {
            this.selMrec.pageNum = newNum
            this.seachMonRec()
        },
        exportExcel () {
            /* generate workbook object from table */
            var wb = XLSX.utils.table_to_book(document.querySelector('#out-table'))
            /* get binary string as output */
            var wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
            try {
                FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), 'sheetjs.xlsx')
            } catch (e) {
                if (typeof console !== 'undefined') console.log(e, wbout)
                }
            return wbout
        }
    }
}
</script>

<style lang="less" scoped>
@import './logMgr.less';
</style>
